#pragma once
#include <Rz/Diagnostics/Assert.h>
#include <Rz/Collections/IList.h>
#include <Rz/Object.h>

#include <initializer_list>

#define RZ_IL(t, ...)	::Rz::Collections::InitializerList<t>({ __VA_ARGS__ })

namespace Rz { namespace Collections {
	
template <typename T>
class InitializerList :
	public Object,
	public IList<T>
{
	public:
		RZ_RTTI(Rz::Collections, InitializerList);
		RZ_RTTI_IMPLEMENTS(Object, IList<T>);
		RZ_RTTI_TEMPLATES(NonObjectType<T>);
		RZ_RTTI_END;

		RZ_TYPEWRAPPER_IMPLEMENT(T);

		typedef typename IEnumerable<T>::ConstIterator ConstIterator;
		typedef typename IEnumerable<T>::Iterator Iterator;


		InitializerList();
		InitializerList(std::initializer_list<T> l);

		InitializerList<T>& operator = (std::initializer_list<T> l);

		// IList
		virtual ConstReference At(SizeType index) const override;
		virtual Reference At(SizeType index) override;

		virtual ConstReference operator [] (SizeType index) const override;
		virtual Reference operator [] (SizeType index) override;

		virtual SizeType GetCount() const override;
		
		// IEnumerable
		virtual ConstIterator ConstBegin() const override;
		virtual ConstIterator ConstEnd() const override;

		virtual Iterator Begin() override;
		virtual Iterator End() override;

	private:
		std::initializer_list<T> _list;
};

} }

#include "InitializerList.inl"
